package com.zhangwei.moni_two.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.web.servlet.HandlerInterceptor;

import com.zhangwei.moni_two.entity.User;

public class MyInterceptor implements HandlerInterceptor{
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
			HttpSession session = request.getSession();
			User attribute = (User) session.getAttribute("login");
			
			if(attribute!=null){
				return true;
			}else{
				response.sendRedirect("toLogin");
				return false;
			}
			
			
	}
	
}
